#pragma once

#include "IPainter.h"
#include <windows.h>
#include "dimension2d.h"

namespace sol9
{
namespace graphics
{

	class Win32Painter : public IPainter
	{
		__declareBaseClass(Win32Painter);

	private:
		HWND m_hDeviceWnd;
		core::dimension2du m_nScreenSize;
		eColorFormat m_eFormat;

		HDC m_hPrimaryBuffer;
		HDC m_hBackBuffer;
		HBITMAP m_hDIBBuffer;
		IImage* m_pBuffer;

	public:
		Win32Painter(HWND hDeviceWnd, core::dimension2du nScreenSize, eColorFormat eFormat);
		~Win32Painter();

		virtual bool initialize();

		virtual bool preDraw();
		virtual bool postDraw();

		virtual void drawPixel(const core::position2di& Position, const color& cColor = 0xffffffff);
		virtual void drawLine(const core::position2di& Pos1, const core::position2di& Pos2, const color& cColor = 0xffffffff);
		virtual void drawImage(const core::position2di& Position, IImage* pImage);

	private:
		void _verticalLine(s32 x1, s32 x2, s32 y);
		void _horizontalLine(s32 x, s32 y1, s32 y2);
		void _bresenhamLine(s32 x1, s32 y1, s32 x2, s32 y2);

	};

} // namespace graphics
} // namespace sol9